package board_mvc.handler;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import board.BoardDBBean;
import board.BoardDataBean;
@Controller
public class ContentAction implements CommandHandler {	
	@Resource( name="instance" )
	BoardDBBean dao;	
	@RequestMapping("/content")
	@Override
	public ModelAndView process(HttpServletRequest request, HttpServletResponse response) {
		Map<String,Object>map=new HashMap<String,Object>();
		int num = Integer.parseInt( request.getParameter( "num" ) );
		int pageNum = Integer.parseInt( request.getParameter( "pageNum" ) );
		int number = Integer.parseInt( request.getParameter( "number" ) );
	
		// BoardDBBean dao = BoardDBBean.getInstance();
		
		dao.addCount( num );
		BoardDataBean dto = dao.getArticle( num );	
				
		map.put("num", num);
		map.put("pageNum", pageNum);
		map.put("number", number);
		map.put("dto", dto);
		
		return new ModelAndView("content",map);
	}

}
